package com.heima.feigns;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.heima.config.HeimaFeignAutoConfiguration;
import com.heima.feigns.fallback.WemediaFeignFallback;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmNews;
import com.heima.model.wemedia.pojos.WmUser;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(
        value = "leadnews-wemedia",
        fallbackFactory = WemediaFeignFallback.class,
        configuration = HeimaFeignAutoConfiguration.class
)
public interface WemediaFeign {
    //根据用户名查询自媒体用户
    @GetMapping("/api/v1/user/findByName/{name}")
    public ResponseResult<WmUser> findByName(@PathVariable String name);
    //保存自媒体用户
    @PostMapping("/api/v1/user/save")
    public ResponseResult<WmUser> saveWmUser(@RequestBody WmUser wmUser);

    @PutMapping("/api/v1/news/update")
    public ResponseResult<WmNews> updateWmNews(@RequestBody WmNews wmNews);

    //根据文章id 查询 文章
    @GetMapping("/api/v1/news/one/{id}")
    @ApiOperation(value = "根据id查询文章")
    public ResponseResult<WmNews> findWmNewsById(@PathVariable Integer id);
}
